﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.ChangeCustomBGM, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_ChangeCustomBGM : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.ChangeCustomBGM;

        public override string name => LevelEditorConst.ChangeCustomBGM;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.ChangeCustomBGM, "RegionInstance表ID(更改BGM的地区)")]
        public int regionCid;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.ChangeCustomBGM, "播放情况或Audio表ID")]
        public int audioCid;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_ChangeCustomBGM()
            {
                regionCid = this.regionCid,
                audioCid = this.audioCid,
            };
            return rConfig;
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (tempNode is LevelServiceExecutionNode_ChangeCustomBGM rNode)
            {
                this.regionCid = rNode.regionCid;
                this.audioCid = rNode.audioCid;
            }
        }
    }
}